/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            shopAccountManageInfo: {
                shopAccounts: [],
                total: 0,
                records: 1,
                moreCondition: false,
                scId: '',
                conditions: {
                    state: '',
                    communityId: '',
                    communityName: '',
                    shopId: vc.getCurrentCommunity().shopId
                }
            }
        },
        _initMethod: function () {
            $that._listshopAccounts(DEFAULT_PAGE, DEFAULT_ROWS);
        },
        _initEvent: function () {
            vc.on('shopAccountManage', 'listshopAccount', function (_param) {
                $that._listshopAccounts(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                $that._listshopAccounts(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            _listshopAccounts: function (_page, _rows) {
                $that.shopAccountManageInfo.conditions.page = _page;
                $that.shopAccountManageInfo.conditions.row = _rows;
                var param = {
                    params: $that.shopAccountManageInfo.conditions
                };
                //发送get请求
                vc.http.apiGet('/account/queryAccount',
                    param,
                    function (json, res) {
                        var _shopAccountManageInfo = JSON.parse(json);
                        $that.shopAccountManageInfo.total = _shopAccountManageInfo.total;
                        $that.shopAccountManageInfo.records = _shopAccountManageInfo.records;
                        $that.shopAccountManageInfo.shopAccounts = _shopAccountManageInfo.data;
                        vc.emit('pagination', 'init', {
                            total: $that.shopAccountManageInfo.records,
                            dataCount: $that.shopAccountManageInfo.total,
                            currentPage: _page
                        });
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _queryshopAccountMethod: function () {
                $that._listshopAccounts(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            _openAddAccountWithdrawalApplyModal: function (_shopAccount) {
                vc.emit('addAccountWithdrawalApply', 'openAddAccountWithdrawalApplyModal', _shopAccount);
            },
            _moreCondition: function () {
                if ($that.shopAccountManageInfo.moreCondition) {
                    $that.shopAccountManageInfo.moreCondition = false;
                } else {
                    $that.shopAccountManageInfo.moreCondition = true;
                }
            },
            _toPayGold: function () {
                vc.jumpToPage('/#/pages/goods/buyGold')
            }
        }
    });
})(window.vc);
